﻿using Basic.FormCollect;
using Basic.FormLocalEvent.Model;
using Basic.FormModel.DB;
using Basic.FormRemoteModel.QueryTable.Model;
using Basic.FormService.Interface;
using WeDonekRpc.Client;

namespace Basic.FormService.lmpl
{
    internal class PhyQueryTableService : IPhyQueryTableService
    {
        private readonly IQueryTableCollect _Table;

        public PhyQueryTableService ( IQueryTableCollect table )
        {
            this._Table = table;
        }
        public PhyQueryTableData Get ( long id )
        {
            DBPhysicalQueryTable table = this._Table.Get(id);
            return table.ConvertMap<DBPhysicalQueryTable, PhyQueryTableData>();
        }
        public long Add ( PhyQueryTableAdd add )
        {
            return this._Table.Add(add, false);
        }
        public bool Set ( long id, PhyQueryTableSet data )
        {
            DBPhysicalQueryTable table = this._Table.Get(id);
            return this._Table.Set(table, data);
        }
        public void Delete ( long id )
        {
            DBPhysicalQueryTable table = this._Table.Get(id);
            this._Table.Delete(table);
            new PhyQueryTableEvent(table).Send("Delete");
        }
    }
}
